<template>
  <div class="login-bg">
    <el-card class="login-card">
      <div class="login-logo-title">
        <img src="@/assets/logo_v1.png" class="login-logo" />
        <div class="login-title">文件管理系统</div>
      </div>
      <div class="login-subtitle">欢迎使用，支持群晖NAS文件管理</div>
      <el-form @submit.prevent="onLogin" :model="form">
        <el-form-item>
          <el-input v-model="form.account" placeholder="账号" size="large">
            <template #prefix>
              <el-icon><User /></el-icon>
            </template>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="form.passwd" type="password" placeholder="密码" size="large">
            <template #prefix>
              <el-icon><Lock /></el-icon>
            </template>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" native-type="submit" :loading="loading" block size="large" class="login-btn">
            登录
          </el-button>
        </el-form-item>
      </el-form>
      <div class="login-copyright">邮箱:shibaizhelianmeng@163.com</div>
    </el-card>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { login } from '../api'
import { User, Lock } from '@element-plus/icons-vue'

const emit = defineEmits(['login-success'])
const form = ref({ account: '', passwd: '' })
const loading = ref(false)

const onLogin = async () => {
  loading.value = true
  try {
    const res = await login(form.value.account, form.value.passwd)
    emit('login-success', res.sid)
    ElMessage.success('登录成功')
  } catch {
    ElMessage.error('登录失败')
  }
  loading.value = false
}
</script>

<style scoped>
.login-bg {
  position: fixed;
  left: 0; top: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  min-width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  z-index: 0;
}
.login-logo-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}
.login-logo {
  width: auto;
  height: 64px;
  max-width: 120px;
  max-height: 80px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  object-fit: contain;
  margin-bottom: 2px;
}
.login-title {
  text-align: center;
  font-size: 2.1rem;
  font-weight: bold;
  color: #409eff;
  letter-spacing: 2px;
  margin-top: 0;
}
.login-subtitle {
  text-align: center;
  font-size: 1.1rem;
  color: #888;
  margin-bottom: 28px;
  letter-spacing: 1px;
}
.login-btn {
  background: linear-gradient(90deg, #409eff 0%, #6c5ce7 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(64,158,255,0.10);
  transition: box-shadow 0.2s, transform 0.2s;
}
.login-btn:hover {
  box-shadow: 0 4px 16px rgba(64,158,255,0.18);
  transform: translateY(-2px) scale(1.04);
}
.login-card {
  width: 440px;
  max-width: 96vw;
  padding: 48px 36px 36px 36px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.13);
  border-radius: 22px;
  background: rgba(255,255,255,0.98);
  z-index: 1;
}
.login-copyright {
  text-align: center;
  color: #aaa;
  font-size: 0.98rem;
  margin-top: 18px;
  letter-spacing: 1px;
}
@media (max-width: 600px) {
  .login-card {
    width: 98vw;
    padding: 18px 4px 18px 4px;
    border-radius: 12px;
  }
  .login-title {
    font-size: 1.2rem;
  }
  .login-logo {
    width: 32px;
    height: 32px;
  }
}
</style> 